/**
* Copyright 2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

* http://www.apache.org/licenses/LICENSE-2.0

* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.

* File utils.cpp
* Description: handle file operations
*/
#include "retina/utils_retina.h"
#include <map>
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <cstring>
#include <dirent.h>
#include <vector>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
// #include "acl/acl.h"


// void UtilsRetina::SendStrikePoint(vector<BBox>& rlts, int fd)
// {
//     Frame1 frame = {0};
//     int sp_num = rlts.size();

//     mtxImageId.lock();
//     uint32_t image_id = imageID.front();
//     imageID.pop();
//     mtxImageId.unlock();

//     frame.head = HEAD_FLAG1;
//     frame.len = 30 + sp_num * 16;
//     frame.id = 0x5A5A0077;
//     frame.seq = 0;
//     frame.num = 1;
//     frame.tail = 0x0A0D24;

//     frame.frm_body.uint8[0] = 0x5A;
//     frame.frm_body.uint8[1] = 0x4A;
//     frame.frm_body.uint8[2] = 6 + sp_num * 16;
//     frame.frm_body.uint32[1] = image_id;

//     for(int i = 0; i < sp_num; i++)
//     {
//         frame.frm_body.uint32[2 + 0 + i * 4] = rlts[i].cls_id;
//         frame.frm_body.uint16[6 + 0 + i * 8] = rlts[i].rect.x;
//         frame.frm_body.uint16[6 + 1 + i * 8] = rlts[i].rect.y;
//         frame.frm_body.uint16[6 + 2 + i * 8] = rlts[i].rect.x + rlts[i].rect.width;
//         frame.frm_body.uint16[6 + 3 + i * 8] = rlts[i].rect.y + rlts[i].rect.height;
//         frame.frm_body.uint32[5 + 0 + i * 4] = rlts[i].score * 100;
//     }

//     unsigned char buffer[30 + sp_num * 16];
//     memcpy(buffer, &frame, 30 + sp_num * 16);
//     unsigned char check = 0;
//     unsigned short crc = Crc16Fast(frame.frm_body.uint8+2, 6 + sp_num * 16, 0);

//     buffer[24 + sp_num * 16] = crc;
//     buffer[25 + sp_num * 16] = crc >> 8;

//     for(int i = 8; i < 26 + sp_num * 16; i++)
//     {
//         check +=  buffer[i];
//     }
//     buffer[29 + sp_num * 16] = check;
//     buffer[26 + sp_num * 16] = frame.tail;
//     buffer[27 + sp_num * 16] = frame.tail >> 8;
//     buffer[28 + sp_num * 16] = frame.tail >> 16;

//     atpSendFrame(buffer, fd, 30 + sp_num * 16);
// }
